namespace CSharpPro._0925;

public class Demo
{
    public void TestPrint(int year)
    {
        bool flag = (year % 4 == 0 && year % 100 != 0)||(year % 400 == 0);
        Console.WriteLine($"{year}年{(flag ? "是" :"不是")}闰年");
    }
    public void TestPrint2()
            {
                const double originalPrice = 8800;
                double discount = 0;
                int month;
                string transport;
                
                while (true)
                {
                    Console.Write("请输入出行月份（1-12）：");
                    if (int.TryParse(Console.ReadLine(), out month) && month >= 1 && month <= 12)
                    {
                        break;
                    }
                    Console.WriteLine("月份输入无效，请重新输入1-12之间的整数！");
                }
                
                while (true)
                {
                    Console.Write("请输入交通方式（航班/动车）：");
                    transport = Console.ReadLine()?.Trim();
                    if (transport == "航班" || transport == "动车")
                    {
                        break;
                    }
                    Console.WriteLine("交通方式输入无效，请仅输入“航班”或“动车”！");
                }
                
                if (month >= 5 && month <= 10)
                {
                    discount = transport == "航班" ? 0.9 : 0.75;
                }
                else
                {
                    discount = transport == "航班" ? 0.6 : 0.3;
                }
                
                double finalPrice = Math.Round(originalPrice * discount, 2);
                
                Console.WriteLine($"\n出行信息：{month}月，{transport}出行");
                Console.WriteLine($"原价：{originalPrice:C}");
                Console.WriteLine($"折扣：{discount:P}");
                Console.WriteLine($"最终价格：{finalPrice:C}");
                
                Console.WriteLine("\n按任意键退出...");
                Console.ReadKey();
            }
        }